using System;

namespace iBeaconScanner_NETMF
{
    public class iBeaconData
    {
        public string DeviceName;

        public byte[] Addr;
        public ushort Major;
        public ushort Minor;
        public sbyte Rssi;
        public sbyte TxCalibratedPower;
        public bool IsAppleiBeacon;

        public enum DeltaScanningStateEnum
        {
            Default,
            In,
            AlreadyDetected
        }

        public DeltaScanningStateEnum DeltaScanningState;

        public double Range
        {
            get
            {
                var ratio_db = TxCalibratedPower - Rssi;
                var ratio_linear = Math.Pow(10, ratio_db / 10.0);

                var r = Math.Sqrt(ratio_linear);

                return r;
            }
        }

        public override string ToString()
        {
            return "[Name:" + DeviceName + ", " +
                "Addr:" + Addr.ToHexStringReversed() + ", " +
                "Major:" + Major + ", " +
                "Minor:" + Minor + ", " +
                "Range:" + Range + ", " +
                "RSSI:" + Rssi + ", " +
                "TxPower:" + TxCalibratedPower +
                "IsApple iBeacon: " + IsAppleiBeacon + "]";
        }
    }
}
